<template>
  <HuilanBasic :left-width="250">
    <template v-slot:left>
      <div style="height: 100%; overflow-y: scroll">
        <basic-container style="padding: 20px">
          <avue-tree
            ref="dimensionTree"
            :option="treeOption"
            :data="treeData"
            @node-click="nodeClick"
            @get-node="getNode"
            highlight-current="true"
            v-if="importSuccessFlag"
          >
            <span
              class="custom-tree-node el-tree-node__label"
              style=" -webkit-box-flex: 1;
              -ms-flex: 1;
              flex: 1;
              display: -webkit-box;
              display: -ms-flexbox;
              display: flex;
              width: 0;"
              slot-scope="{ node, data }"
              @mouseenter="mouseenter(data)"
              @mouseleave="mouseleave(data)"
            >
              <span class="kw-nodeName" :title="(node || {}).label">
                {{ (node || {}).label }}
              </span>
              <span v-if="data.isShow">
                  <!-- 新增 -->
                <i
                  v-if="permission[`${prefix}angle-type-add`] && data.id==0"
                  class="el-icon-plus"
                  style="color: #409eff"
                  :title="$t('answerViewManage.buildViewType')"
                  @click.stop="addCate"
                ></i>
                  <!-- 编辑 -->
                <i
                  v-if="permission[`${prefix}angle-type-edit`] && data.id!=0"
                  class="el-icon-edit"
                  style="color: #409eff"
                  :title="$t('aicosCommon.editBtn')"
                  @click.stop="editCate(data)"
                ></i>
                   <!-- 删除 -->
                <i
                  v-if="permission[`${prefix}angle-type-delete`] && data.id!=0"
                  class="el-icon-delete"
                  style="color: #dd3a24"
                  :title="$t('answerViewManage.delViewType')"
                  @click.stop="deleteCate(data)"
                ></i>
              </span>
            </span>
          </avue-tree>
        </basic-container>
      </div>
    </template>
    <div class="">
      <div
        class="kw-right-container"
        :style="{
          height: allWindowTopBodyHeight ? allWindowTopBodyHeight + 'px' : '',
          marginLeft: '20px',
        }"
      >
        <avue-crud
          :option="option"
          :data="data"
          :permission="permissionList"
          ref="crudTemplateTable"
          @row-click="getOpenDetail"
          :page.sync="page"
          :table-loading="loading"
          @select="checkboxIsChange"
          @select-all="checkboxIsAllChange"
          @current-change="currentChange"
          @size-change="sizeChange"
        >
          <template slot="header">
            <div class="kw-header">
              <div class="kw-button-container">
                <el-button
                  @click="addDomain"
                  class="kw-build-button kw-btn-green"
                  v-if="permission[`${prefix}angle-add`] && this.selectedCateId != ''&&this.selectedCateId!= '0'"
                  >{{ $t("answerViewManage.buildDomain") }}</el-button
                >

                <el-button
                  type="primary"
                  size="small"
                  @click="viewImport"
                >
                  答案视角导入
                </el-button>

                <el-button
                  type="primary"
                  size="small"
                  @click="viewExport"
                >
                  答案视角导出
                </el-button>
              </div>
              <div id="kw-form-container">
                <div class="kw-form-form">
                  <el-input
                    :placeholder="$t('answerViewManage.viewName')"
                    v-model="viewName"
                    size="small"
                    clearable
                    class="kw-form-type"
                  >
                  </el-input>
                </div>
                <div class="kw-form-btn">
                  <el-button
                    type="primary"
                    icon="el-icon-search"
                    class="kw-search-btn"
                    @click="handlerSearch"
                    size="small"
                  ></el-button>
                  <el-button
                    class="kw-reset-btn"
                    @click="handlerReset"
                    size="small"
                    ><i class="aicosicon aicos-icon-clear"></i
                  ></el-button>
                </div>
              </div>
            </div>
          </template>
          <template slot-scope="scope" slot="menu">
            <el-button
              type="text"
              size="small"
              v-if="
                scope.row.level == 1 && permission[`${prefix}angle-addChildren`]
              "
              @click.stop="handlerAddDomain(scope.row, scope.index)"
              >{{ $t("answerViewManage.buildChildDomain") }}</el-button
            >
            <el-button
              type="text"
              size="small"
              v-if="
                scope.row.level != 1 && permission[`${prefix}angle-addChildren`]
              "
              @click.stop="handlerAddDomain(scope.row, scope.index)"
              >{{ $t("answerViewManage.buildChildDomain") }}</el-button
            >
            <el-button
              type="text"
              size="small"
              v-if="permission[`${prefix}angle-edit`]"
              @click.stop="handlerEdit(scope.row, scope.index)"
              >{{ $t("aicosCommon.editBtn") }}</el-button
            >
            <el-button
              type="text"
              size="small"
              v-if="
                scope.row.indexLine[scope.row.indexLine.length - 1] != 0 &&
                permission[`${prefix}angle-up`]
              "
              @click.stop="goWhere(scope, true)"
              >{{ $t("aicosCommon.moveUp") }}</el-button
            >
            <el-button
              type="text"
              size="small"
              v-if="
                scope.row.indexLine[scope.row.indexLine.length - 1] + 1 !=
                  scope.row.parentLength && permission[`${prefix}angle-down`]
              "
              @click.stop="goWhere(scope, false)"
              >{{ $t("aicosCommon.moveDown") }}</el-button
            >
            <el-button
              type="text"
              size="small"
              class="kw-del-btn"
              v-if="permission[`${prefix}angle-delete`]"
              @click.stop="handlerDel(scope.row, scope.index)"
              >{{ $t("aicosCommon.delBtn") }}</el-button
            >
          </template>
        </avue-crud>
      </div>
    </div>
    <HuilanDialog
      :title="
        isEdit
          ? $t('answerViewManage.editViewTypeName')
          : $t('answerViewManage.viewTypeName')
      "
      append-to-body
      :visible.sync="viewTypeFlag"
      width="600px"
    >
      <el-form
        :label-position="labelPosition"
        :model="ruleForm"
        :rules="rules"
        v-if="viewTypeFlag"
        ref="rule"
        label-width="120px"
        class="demo-ruleForm"
      >
        <el-form-item
          :label="$t('answerViewManage.name') + ':'"
          prop="typeName"
        >
          <el-input
            v-model="ruleForm.typeName"
            maxlength="10"
            show-word-limit
          ></el-input>
        </el-form-item>
      </el-form>

      <template v-slot:footer>
        <el-button size="small" @click="viewTypeFlag = false">{{
          $t("aicosCommon.cancelBtn")
        }}</el-button>
        <el-button
          size="small"
          type="primary"
          @click="saveViewType"
          :disabled="btnDisable"
          >{{ $t("aicosCommon.saveBtn") }}</el-button
        >
      </template>
    </HuilanDialog>

    <QSGDrawer
      :title="
        isEdit
          ? $t('answerViewManage.editViewDetail')
          : $t('answerViewManage.viewDetail')
      "
      append-to-body
      :visible.sync="viewNameFlag"
      size="600px"
    >
      <el-form
        :label-position="labelPosition"
        :model="typeNameForm"
        v-if="viewNameFlag"
        :rules="rules"
        ref="typeNameForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item :label="$t('answerViewManage.names') + ':'" prop="name">
          <el-input
            v-model="typeNameForm.name"
            maxlength="15"
            show-word-limit
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('answerViewManage.encoding') + ':'"
          prop="code"
        >
          <el-input
            v-model="typeNameForm.code"
            maxlength="30"
            show-word-limit
          ></el-input>
        </el-form-item>
        <el-form-item :label="$t('answerViewManage.desc') + ':'" prop="desc">
          <el-input
            type="textarea"
            v-model="typeNameForm.desc"
            maxlength="200"
            show-word-limit
          ></el-input>
        </el-form-item>
      </el-form>

      <template v-slot:footer>
        <el-button size="small" @click="viewNameFlag = false">{{
          $t("aicosCommon.cancelBtn")
        }}</el-button>
        <el-button
          size="small"
          type="primary"
          @click="saveViewName"
          :disabled="disabled"
          >{{ $t("aicosCommon.saveBtn") }}</el-button
        >
      </template>
    </QSGDrawer>

    <HuilanDialog
      title="答案视角导入"
      append-to-body
      :visible.sync="importFlag"
      width="600px"
      @beforeClose="beforeClose"
    >
      <Import
        ref="import"
        v-if="importFlag"
        @successImport="successImport"
      />
      <template v-slot:footer>
        <el-button size="small" @click="importFlag = false">
          {{$t("aicosCommon.cancelBtn") }}
        </el-button>
        <el-button
          size="small"
          type="primary"
          @click="handlerSave"
          :disabled="importBtn"
        >
          {{ $t("aicosCommon.saveBtn") }}
        </el-button>
      </template>

    </HuilanDialog>

  </HuilanBasic>
  <!--<someComponent></someComponent>-->
</template>

<script>
import Import from './import.vue';
import serviceList from "@/config/serviceList";
import {
  angleTypeList,
  saveOrUpdate,
  viewDelete,
  angleList,
  angelSaveOrUpdate,
  changeOrder,
} from "@/api/kwKnowledgeCenter/kwSettings/kwAnswerViewManage/index";
import { getRules } from "@/util/regx";
import { mapGetters } from "vuex";
import QSGDrawer from "@/components/QSGDrawer/index";
import {baseURL} from "@/api/common";
const { knowledge } = serviceList;
export default {
  inject: ["desktopWindow", "desktop", "isRobotMenu"],
  name: "",
  data() {
    let allDimensionText = this.$t("dimensionManage.allDimensionText");
    let botId = this.$store.getters.botObj.id;
    const me = this;
    return {
      importSuccessFlag:false,
      importFlag:false,
      importBtn:false,
      btnDisable: false,
      disabled: false,
      isEdit: false,
      allWindowTopBodyHeight: 0, //窗口的高度
      isSearch: false,
      cur: {},
      loading: false,
      editFlag: false, //编辑或新增区分的标识
      selectedCateId: "", //默认左侧列表id
      selectedCateName: "", //默认左侧列表的名字
      viewTypeFlag: false, //视角类型标识
      viewNameFlag: false,
      botId: "", //机器人id
      viewTypeList: [], //视角类型列表
      viewName: "", //搜索用的视角名称
      tableListId: "", //列表数据的id
      data: [],
      page: {
        total: 0,
        currentPage: 1,
        pageSize: 10,
      },
      option: {
        // selection: true,
        rowKey: "id",
        rowParentKey: "ancestors",
        height: 550,
        menuWidth: 260,
        addBtn: false,
        editBtn: false,
        viewBtn: false,
        delBtn: false,
        searchBtn: false,
        columnBtn: false,
        refreshBtn: false,
        stripe: true,
        emptyText: this.$t('aicosCommon.notData'),
        column: [
          {
            label: this.$t("answerViewManage.viewName"), //视角名称
            prop: "name",
          },
          {
            label: this.$t("answerViewManage.encoding"),
            prop: "code",
            rules: [
              {
                pattern: /^[a-z0-9]+$/,
                message: this.$t("answerViewManage.numberTips"),
              },
            ],
          },
          {
            label: this.$t("answerViewManage.desc"), //类型
            prop: "remake",
          },
        ],
      },
      ruleForm: {
        typeName: "",
      },
      typeNameForm: {
        name: "",
        code: "",
        desc: "",
      },
      rules: {
        typeName: {
          required: true,
          message: this.$t("answerViewManage.viewTypeTips"),
          trigger: "blur",
        },
        code: {
          pattern: /^[a-z0-9]+$/,
          message: this.$t("answerViewManage.lowercaseTips"),
          trigger: "blur",
        },
        name: [
          {
            required: true,
            message: this.$t("answerViewManage.viewNameTips"),
            trigger: "blur",
          },
          ...getRules(["charNumHan"]),
        ],
      },

      treeData: [],
      treeOption: {
        menu: false,
        addBtn: true,
        filter: false,
        nodeKey: "id",
        lazy: true,
        props: {
          label: "name",
          children: "children",
          // 设置了value后getNode才能通过key获取节点
          value: "id",
        },
        defaultExpandedKeys: ["0"],
        treeLoad: function (node, resolve) {
          if (node.level === 0) {
            resolve([{ name: allDimensionText, id: "0" }]);
            return;
          }
          const parentId = node.data.id;
          angleTypeList({
            botId: botId,
          }).then((res) => {
            setTimeout(() => {
              if (res.data.data.length > 0 && parentId === "0") {
                me.$refs.dimensionTree.setCurrentKey(res.data.data[0].id);
                me.nodeClick(res.data.data[0]);
              }
            });
            resolve(
              res.data.data.map((item) => {
                return {
                  ...item,
                  leaf: item.isLeaf === 0,
                };
              })
            );
          });
        },
      },
      form: {},
      query: {
        name: "",
      },
      editTreeData: {},
      parentId: "0",
    };
  },
  components: {
    //someComponent
    QSGDrawer,
    Import
  },
  computed: {
    prefix() {
      const prefix = this.isRobotMenu ? "robot-" : "";
      return prefix;
    },
    // 计算属性
    ...mapGetters(["permission", "language",'botObj']),
    labelPosition() {
      return this.language != "zh" ? "top" : "right";
    },
  },
  methods: {

    getNode(data) {
      this.node = data.node;
      this.resolve = data.resolve;
    },

    //动态获取窗口大小
    desktopWindowResize() {
      this.allWindowTopBodyHeight =
        this.desktopWindow.$el.getElementsByClassName(
          "desk-window-inner"
        )[0].offsetHeight;
    },

    viewImport(){
      //答案视角导入
      this.importFlag = true
    },


    viewExport(){
      //答案视角导出
      window.open(`${baseURL}api/${knowledge}/huilan-km-answer-angle/export?botId=${this.botId}`,'_self');
    },

    handlerSave(){
      this.importBtn = true;
      this.$refs.import.saveImport();
    },

    successImport(type) {
      this.importBtn = false;
      if (type) {
        this.importSuccessFlag = false;
        this.importFlag = false;
        setTimeout(()=>{
          this.importSuccessFlag = true
        },100)
        // this.onLoad();
        this.$refs.dimensionTree.$refs.tree.clearNode();
        this.$refs.dimensionTree.$refs.tree.loadNode(this.node, this.resolve);
      }
    },

    getOpenDetail(row) {
      this.$refs.crudTemplateTable.toggleRowExpansion(row);
    },

    //获取右侧表格数据

    onLoad() {
      let that = this;
      this.$nextTick(async () => {
        setTimeout(async () => {
          this.loading = true;
          const tableInfo = {
            botId: this.botId,
            current: this.page.currentPage,
            size: this.page.pageSize,
            name: this.viewName,
          };
          tableInfo.id = that.selectedCateId;
          tableInfo.topNode = that.selectedCateId;
          const result = await angleList(tableInfo);
          this.option.menuWidth = this.language != "zh" ? 390 : 260;
          if (result.data.code == 200) {
            const Data = result.data.data;
            this.page.total = Data.total;
            this.data = Data.records;
            this.tableDataHandle(this.data, "children");
            this.loading = false;
          }
        }, 100);
      });
    },

    currentChange(page) {
      this.page.currentPage = page;
      this.onLoad();
    },

    sizeChange(size) {
      this.page.currentPage = 1;
      this.page.pageSize = size;
      this.onLoad();
    },

    //处理获取到的树型表格数据
    tableDataHandle(arr, key, level = 0, indexLine = []) {
      level = level + 1;
      arr.map((item, idx) => {
        item.level = level;
        item.indexLine = Object.assign([], indexLine);
        item.indexLine.push(idx);
        item.parentLength = arr.length;
        if (item[key]) {
          this.tableDataHandle(item[key], key, level, item.indexLine);
        }
      });
      return arr;
    },
    //上移,下移
    goWhere(scrow, flag) {
      this.upAndDown(scrow.row.indexLine, flag, scrow.row);
      this.tableDataHandle(this.data, "children");
    },
    // 精确到父亲
    getParentData(list, row) {
      let children = [];
      let findEle = (arr, data) => {
        arr.forEach((item) => {
          if (item.id == data.id) {
            children = arr;
          } else {
            if (item.children && item.children.length) {
              findEle(item.children, data);
            }
          }
        });
      };
      findEle(list, row);
      return children;
    },
    // 上下移动
    async upAndDown(target, flag, row) {
      let temTable;
      if (target.length == 1) {
        temTable = this.data;
      } else {
        temTable = this.getParentData(this.data, row);
      }
      let index = target[target.length - 1];
      if (flag) {
        //上移
        const moveId = {
          fromId: temTable[index].id,
          todoId: temTable[index - 1].id,
        };
        const result = await changeOrder(moveId);
        if (result.data.code == 200) {
          this.$message({
            type: "success",
            message: this.$t("aicosCommon.successOperate"),
          });
          this.onLoad();
        }
      } else {
        const moveId = {
          fromId: temTable[index].id,
          todoId: temTable[index + 1].id,
        };
        const result = await changeOrder(moveId);
        if (result.data.code == 200) {
          this.$message({
            type: "success",
            message: this.$t("aicosCommon.successOperate"),
          });
          this.onLoad();
        }
      }
    },
    //新增视角类型
    addCate() {
      this.isEdit = false;
      this.editFlag = false;
      this.viewTypeFlag = true;
      this.ruleForm.typeName = "";
      this.selectedCateId = '';
      this.viewName = "";
      this.parentId = '0'
    },
    //编辑视角类型
    editCate(data) {
      this.editTreeData = data
      this.handlerChoose(data.name,data.id)
      this.isEdit = true;
      this.editFlag = true;

      this.viewTypeFlag = true;
      this.ruleForm.typeName = this.selectedCateName;
    },
    //删除视角类型
    deleteCate(data) {
      // this.handlerChoose(data.name,data.id)
      this.selectedCateName = data.name;
      this.selectedCateId = data.id;
      this.viewName = "";
      if (this.selectedCateId == "" || this.selectedCateName == "") {
        this.$message({
          type: "warning",
          message: this.$t("answerViewManage.editViewTypeTips"),
        });
        return;
      } else {
        this.$confirm(this.$t("answerViewManage.delViewTypeTips"), {
          cancelButtonText: this.$t("aicosCommon.cancelBtn"),
          confirmButtonText: this.$t("aicosCommon.confirmBtn"),
          type: "warning",
        })
          .then(async () => {
            const delInfo = {
              id: this.selectedCateId,
            };
            const result = await viewDelete(delInfo);
            if (result.data.code == 200) {
              this.$message({
                type: "success",
                message: this.$t("aicosCommon.deleteSuccessTip"),
              });
              this.selectedCateId = "";
              this.updateTreeNode('del',data);
            }
          })
          .catch(() => {});
      }
    },
    //保存视角类型
    async saveViewType() {
      const info = {
        botId: this.botId,
        name: this.ruleForm.typeName,
      };
      if (this.editFlag) {
        info.id = this.selectedCateId;
      }
      this.$refs.rule.validate(async (valid) => {
        if (valid) {
          this.btnDisable = true;
          saveOrUpdate(info)
            .then((result) => {
              if (result.data.code == 200) {
                this.$message({
                  type: "success",
                  message: this.$t("aicosCommon.saveSuccessTip"),
                });
                this.viewTypeFlag = false;
                this.btnDisable = false;
                this.editTreeData.name = this.ruleForm.typeName
                this.updateTreeNode(this.isEdit?'update':'add',this.editTreeData);
              }
            })
            .catch(() => {
              this.btnDisable = false;
            });
        }
      });
    },
    //点击左侧列表方法
    handlerChoose(name, id) {
      this.selectedCateName = name;
      this.selectedCateId = id;
      this.viewName = "";
      this.onLoad();
    },

    //新增领域
    addDomain() {
      this.isEdit = false;
      this.editFlag = false;
      this.viewNameFlag = true;
      this.typeNameForm.name = "";
      this.typeNameForm.code = "";
      this.typeNameForm.desc = "";
      this.cur = {};
    },
    //新建子级视角
    handlerAddDomain(row) {
      this.cur = row;
      this.isEdit = false;
      this.editFlag = false;
      this.viewNameFlag = true;
      this.typeNameForm.name = "";
      this.typeNameForm.code = "";
      this.typeNameForm.desc = "";
    },
    //编辑领域
    handlerEdit(row) {
      this.viewNameFlag = true;
      this.isEdit = true;
      this.editFlag = true;
      this.tableListId = row.id;
      this.typeNameForm.name = row.name;
      this.typeNameForm.code = row.code;
      this.typeNameForm.desc = row.remake;
    },
    //删除领域数据
    handlerDel(row) {
      this.$confirm(this.$t("answerViewManage.delViewTypeTips"), {
        cancelButtonText: this.$t("aicosCommon.cancelBtn"),
        confirmButtonText: this.$t("aicosCommon.confirmBtn"),
        type: "warning",
      })
        .then(async () => {
          const delInfo = {
            id: row.id,
          };
          const result = await viewDelete(delInfo);
          if (result.data.code == 200) {
            this.$message({
              type: "success",
              message: this.$t("aicosCommon.deleteSuccessTip"),
            });
            this.onLoad();
          }
        })
        .catch(() => {});
    },
    //搜索列表
    handlerSearch() {
      this.onLoad();
      setTimeout(() => {
        this.listIsExpand(this.data, true);
      }, 300);
    },

    //重置搜索结果
    handlerReset() {
      // this.$set(this.option, "defaultExpandAll", false);
      this.viewName = "";
      this.onLoad();
      this.listIsExpand(this.data, false);
    },
    //列表树的展开收起
    listIsExpand(arr, expandFlag) {
      this.loading = true;
      arr.forEach((item) => {
        this.$refs.crudTemplateTable.toggleRowExpansion(item, expandFlag);
        if (item.children) {
          this.listIsExpand(item.children, expandFlag);
        }
      });
      this.loading = false;
    },
    //保存领域
    async saveViewName() {
      let that = this;
      const tableInfo = {
        topNode: that.selectedCateId,
        botId: that.botId,
        name: that.typeNameForm.name,
        remake: that.typeNameForm.desc,
        code: this.typeNameForm.code,
        ancestors: that.cur.id ? that.cur.id : that.selectedCateId, //父级id
        secondNode: that.cur.secondNode ? that.cur.secondNode : that.cur.id, //顶级id
      };
      if (that.editFlag) {
        tableInfo.id = that.tableListId;
      }
      that.$refs.typeNameForm.validate(async (valid) => {
        if (valid) {
          this.disabled = true;
          angelSaveOrUpdate(tableInfo)
            .then((result) => {
              if (result.data.code == 200) {
                that.$message({
                  type: "success",
                  message: that.$t("aicosCommon.saveSuccessTip"),
                });
                this.disabled = false;
                that.viewNameFlag = false;
                that.onLoad();
                setTimeout(() => {
                  if (tableInfo.secondNode != "") {
                    that.getOpenDetail(that.cur);
                  }
                  that.cur = {};
                }, 200);
              }
            })
            .catch(() => {
              this.disabled = false;
            });
        }
      });
    },

    //点击节点
    nodeClick (data) {
      this.handlerChoose(data.name,data.id)
      this.parentId = data.id;
      this.page.currentPage = 1;
      // this.onLoad(this.page);
    },

    mouseenter(data) {
      this.$set(data, "isShow", true);
    },
    mouseleave(data) {
      this.$set(data, "isShow", false);
    },

    updateTreeNode (type, data) {
      const dimensionTree = this.$refs.dimensionTree;
      const curParent = dimensionTree.getNode(this.parentId);
      if (type === "add") {
        if (curParent.isLeaf) {
          curParent.isLeaf = false;
          curParent.loaded = false;
          if (curParent.expanded) {
            curParent.expand();
          }
        } else {
          if (curParent.loaded) {
            curParent.loaded = false;

            if (curParent.expanded) {
              curParent.expand();
            }
          }
        }
      } else if (type === "update") {
        const curNode = dimensionTree.getNode(data.id);
        if (curNode) {
          curNode.data = data;
        }
      } else if (type === "del") {
        dimensionTree.remove(data.id);
      } else if (type == "patchDel") {
        this.selectionList.forEach((node) => {
          dimensionTree.remove(node.id);
        });

        if (curParent.loaded) {
          curParent.loaded = false;

          if (curParent.expanded) {
            curParent.expand();
          }
        }
      } else if (type == "move") {
        if (curParent.loaded) {
          curParent.loaded = false;

          if (curParent.expanded) {
            curParent.expand();
          }
        }
      }
    },
  },
  created() {
    this.botId = this.$store.getters.botObj.id;
  },
  mounted() {

    this.importSuccessFlag = true;

    // 收起左侧菜单
    // if (!this.$store.getters.isCollapse) {
    //   this.$store.commit("SET_COLLAPSE");
    // }
    this.$refs.dimensionTree.setCurrentKey("0");
    // 获取机器人id
    // var query = {};
    if (this.desktopWindow) {
      //获取窗口的大小
      this.allWindowTopBodyHeight =
        this.desktopWindow.$el.getElementsByClassName(
          "desk-window-inner"
        )[0].offsetHeight;
      //监听窗口变化,重新获取新的窗口大小
      this.desktopWindow.$on("resize", this.desktopWindowResize);
    }
    this.botId = this.$store.getters.botObj.id;

    // this.getList();
  },
  beforeDestroy() {
    //组件销毁取消监听
    if (this.desktopWindow) {
      this.desktopWindow.$off("resize", this.desktopWindowResize);
    }
  },
  destroyed() {},
};
</script>

<style lang="scss" scoped>
/deep/ .avue-crud__menu {
  min-height: 0;
}

#profileConfigList {
  padding: 0;
  height: 695px;
}

#profileConfigList .profile-config-item {
  list-style: none;
  height: 30px;
  line-height: 30px;
  padding-left: 10px;
  cursor: pointer;
}

#profileConfigList .profile-config-item:hover {
  background-color: #f2f2f2;
}

#profileConfigList .profile-config-item.item-this {
  background-color: #f2f2f2;
}

#profileConfigList .profile-config-item p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  margin: 0;
  font-size: 14px;
}
//左侧树新改样式
/deep/ .el-card__body {
  padding: 0;
}
.custom-tree-node {
  display: flex;
  justify-content: space-between;
  align-items: center;

  .kw-nodeName {
    font-size: 14px;

    width: 240px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: block;
  }
}
/deep/ .el-tree-node.is-current > .el-tree-node__content {
  background: #f5f7f9 !important;
}

/deep/ .el-tree-node__content span {
  overflow: visible;
}
</style>
